load("@rules_cc//cc:cc_library.bzl", "cc_library")

cc_library(
    name = "boost.dll",
    hdrs = glob(
        ["include/**/*.hpp"],
        exclude = [
            "include/boost/dll/detail/import_mangled_helpers.hpp",
            "include/boost/dll/detail/posix/*",
            "include/boost/dll/detail/windows/*",
            "include/boost/dll/detail/demangling/msvc.hpp",
        ],
    ) + select({
        "@platforms//os:windows": ["include/boost/dll/detail/windows/path_from_handle.hpp"],
        "//conditions:default": ["include/boost/dll/detail/posix/path_from_handle.hpp"],
    }),
    features = ["parse_headers"],
    includes = ["include"],
    linkopts = select({
        "@platforms//os:linux": ["-ldl"],
        "//conditions:default": [],
    }),
    local_defines = select({
        "@platforms//os:windows": ["BOOST_OS_WINDOWS"],
        "//conditions:default": [],
    }),
    textual_hdrs = ["include/boost/dll/detail/import_mangled_helpers.hpp"] + select({
        "@platforms//os:windows": glob(["include/boost/dll/detail/windows/*_impl.hpp"]),
        "//conditions:default": glob(["include/boost/dll/detail/posix/*_impl.hpp"]),
    }),
    visibility = ["//visibility:public"],
    deps = [
        "@boost.assert",
        "@boost.config",
        "@boost.core",
        "@boost.filesystem",
        "@boost.predef",
        "@boost.system",
        "@boost.throw_exception",
        "@boost.type_index",
        "@boost.winapi",
    ],
)
